*** Estimating complier share over time

clear  all
set more off

*** set working directory
cd "/Users/hadomini/Dropbox (PP)/SNF Citizenship/Effects of Citizenship/ReplicationArchiveSocInt"

*** load data
use "finaldata_interviewed.dta"

*** define globals
global XXX  male age kids i.married_cat i.educ_cat i.skill_cat i.residency_cat i.geburtsland_ch i.refugee_cat land_* i.lang_cat i.integration_cat gemeinde_* year_*

*** first stage for estimation sample
reg  treated  ZZ  if margin >-10 & margin <=10, r 
reg  treated  ZZ  $XXX if margin >-10 & margin <=10, r 

*** time between first referendum and interview
gen diff_ref_int_year = 2013-abstimmungsjahr

*** time between first referendum and naturalization
gen diff_nat_ref_year = yearofnat - abstimmungsjahr
replace diff_nat_ref_year=0 if diff_nat_ref_year<0
replace diff_nat_ref_year=0 if ZZ==1


*** some descriptives
bysort ZZ:  sum diff_nat
tab diff_nat if ZZ==0

*** approximating complier share over time
forvalues i = 0(1)15 {
	gen nat_`i' = 0
	replace nat_`i' = 1 if ZZ==1
	replace nat_`i' = 1 if diff_nat_ref_year<=`i' & ZZ==0
	reg  nat_`i'  ZZ  if margin >-10 & margin <=10, r 
}

